package main

import (
	"crypto/hmac"
	"crypto/sha256"
	"fmt"
)

func main() {
	HmacSha256("test")
}

//类似于php hash_hmac('sha256', $param, $appkey)
func HmacSha256(param string) {
	var key = []byte("123")

	h := hmac.New(sha256.New, key)
	h.Write([]byte(param))

	expectedMAC := h.Sum(nil)
	fmt.Println(fmt.Sprintf("%x", expectedMAC))
}
